package com.heima.model.common.whitelist;

import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author XHui
 * @Since 2024/3/6 15:37
 * @Version 1.0
 */
@Data
public class WhiteList {

    private static List<String> whiteList = new ArrayList<>();

    public static class Knife4jWhiteList{
        private static List<String> knife4jWhiteList = new ArrayList<>();

        // 初始化白名单 url路径
        static {
            knife4jWhiteList.add("/login/in");
            knife4jWhiteList.add("/doc.html");
            knife4jWhiteList.add("/webjars");
            knife4jWhiteList.add("/swagger");
            knife4jWhiteList.add("/v2/api-docs"); // 通过网关整合文档
        }

        public  static List<String> list() {
             return knife4jWhiteList;
         }

    }


    public static boolean isPass(List<String> whiteList, String reqUrl) {
        for (String url : whiteList) {
            if (reqUrl.contains(url)) {
                return true;
            }
        }
        return false;
    }

}
